package com.itheima;

import com.itheima.domain.Account;
import com.itheima.service.AccountService;
import com.itheima.service.impl.AccountServiceImpl;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class AppForSpringMybatis {
    public static void main(String[] args) {
        //TODO 1.创建JdbcConfig        定义DataSource
        //TODO 2.创建MybatisConfig     定义SqlSessionFactoryBean , MapperScannerConfigurer
        //TODO 3.创建springConfig      扫描service层,加载jdbc.properties,加载JdbcConfig和MybatisConfig


        //TODO 4.创建IOC容器,从IOC容器中获取AccountServiceImpl,运行AccountServiceImpl类中的方法     提示:AnnotationConfigApplicationContext
        AnnotationConfigApplicationContext ac=new AnnotationConfigApplicationContext("com.itheima.config.SpringConfig");
        AccountService bean = ac.getBean(AccountService.class);
        List<Account> all = bean.findAll();
        System.out.println(all);


    }
}
